package com.jindu.producer.system.jpa;

import com.jindu.producer.system.model.SMenuEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Transactional
public interface MenuJpa extends JpaRepository<SMenuEntity,Long>,JpaSpecificationExecutor {

    SMenuEntity findById(String id);

    List<SMenuEntity> findAllByParentId(String parentId);

    @Modifying
    @Query("delete from SMenuEntity where id = ?1 ")
    int deleteById(String id);

}
